﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class controls_usrNoOfDays : System.Web.UI.UserControl
{
    protected int intNoOfDays = -1;
    protected string strValidatinoGroup = "";
    protected string strErrorMessage = "Choose No Of Days";
    protected bool bEnabled = true;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ddlNoOfDays.Attributes.Add("onblur", "ShowValidationEffect('" + ddlNoOfDays.ClientID + "','" + rfvNoOfDays.ClientID + "');");
        }
    }

    public bool IsEnabled
    {
        get { return bEnabled; }
        set
        {
            bEnabled = value;
            SetEnabled();
        }
    }

    public void IsEnableValidation(bool bValue)
    {
        rfvNoOfDays.Enabled = bValue;
    }

    public int NoOfDays
    {
        get { return intNoOfDays; }
        set { intNoOfDays = value; }
    }

    public string ValidationGroup
    {
        get { return strValidatinoGroup; }
        set { strValidatinoGroup = value; }
    }

    public string ErrorMessage
    {
        get { return strErrorMessage; }
        set { strErrorMessage = value; }
    }

    private void SetEnabled()
    {
        ddlNoOfDays.Enabled = bEnabled;
        rfvNoOfDays.Enabled = bEnabled;
    }

    public int GetNoOfDays()
    {
        intNoOfDays = Convert.ToInt32(ddlNoOfDays.SelectedValue);
        return intNoOfDays;
    }

    protected override void OnPreRender(EventArgs e)
    {
        ddlNoOfDays.SelectedValue = Convert.ToString(intNoOfDays);
    }

}
